package com.demomaster.quickaccessibility.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.demomaster.quickaccessibility.core.QuickAccessibility;

public class ScreenStateReceiver extends BroadcastReceiver {

    private static final String TAG = "ScreenStateReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
            // 屏幕亮起
            Log.d(TAG, "Screen is ON");
            QuickAccessibility.getInstance().setScreenOn(true);
        } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
            // 屏幕熄灭
            Log.d(TAG, "Screen is OFF");
            QuickAccessibility.getInstance().setScreenOn(false);
        }
    }
}